package com.parking.carsystem.parkingchargesystem.view;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;

import com.parking.carsystem.parkingchargesystem.utils.DisplayUtil;


/**
 * @author: caoww
 * @date: 2020-02-20
 * @Description:
 */
public class TopImageTextView extends AppCompatTextView {
    public TopImageTextView(Context context) {
        this(context, null);
    }

    public TopImageTextView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public TopImageTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        Drawable[] compoundDrawables = getCompoundDrawables();
        compoundDrawables[1].setBounds(0, 0, DisplayUtil.dip2px(getContext(), 23), DisplayUtil.dip2px(getContext(), 23));//第一个 0 是距左边距离，第二个 0 是距上边距离，40 分别是长宽
        setCompoundDrawables(null, compoundDrawables[1], null, null);//只放左边
    }
}
